
/*****************************************************************************
 * (C) Copyright 2012 QOROS-Automotive
 * FILE NAME:    hwa_outputs.c
 * DESCRIPTION:  Module to control output pins
 * DATE BEGUN:
 * BY:
 * PRODUCT NAME:
 * APPLICATION:  ouput control
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

#define hwa_outputs_c

/* #include */

#include "system.h"
#include "hwa_outputs_cfg.h"
#include "hwa_outputs.h"

/* #define */

/* Macros */

/* typedef */

/* static variables */
 UINT8 DebugTest2;

/* static constants */


/****************************************************************************/
/**
 * Function Name: HWA_SetOutput
 * Description: none
 *
 * Param:   u8_outputIdx: output index
            u8_cmd: PWM_OUT 0~100
                    MCU_OUT ON or OFF
                    LSD_OUT ON or OFF
 * Return:  none
 * Author:  YONG.DING
 ****************************************************************************/
void HWA_SetOutput(UINT8 u8_outputIdx, UINT8 u8_cmd)
{
    UINT8 *p_u8_port=NULL;
    UINT8 u8_pinIdx;

    //read detail in config table
    p_u8_port = (UINT8 *)c_s_DOUT_CONFIG[u8_outputIdx].u8_portName;
    u8_pinIdx = c_s_DOUT_CONFIG[u8_outputIdx].u8_pinIndex;
    

    if(c_s_DOUT_CONFIG[u8_outputIdx].u8_outputType == MCU_OUT)
    {
        if(u8_cmd == OFF)// OFF
        {    
             if(c_s_DOUT_CONFIG[u8_outputIdx].u8_activeLevel == H){
                *p_u8_port &=  (UINT8)(~(1 << u8_pinIdx));
             }else{
                *p_u8_port |= (UINT8)(1 << u8_pinIdx);
             }
            //HWA_SstOutputOff(u8_outputIdx, u8_port, u8_pinIdx);
        }
        else
        {    
             if(c_s_DOUT_CONFIG[u8_outputIdx].u8_activeLevel == H){
                *p_u8_port |= (UINT8)(1 << u8_pinIdx); 
                 // PTJ |= (1 << u8_pinIdx);
             }else{
                *p_u8_port &= (UINT8)(~(1 << u8_pinIdx));
             }
            //HWA_SstOutputOn(u8_outputIdx, u8_port, u8_pinIdx);
        }
    }
    else if(c_s_DOUT_CONFIG[u8_outputIdx].u8_outputType == PWM_OUT)
    {

    }
    else
    {
    }
  

}


/*************************end of hwa_outputs.c********************************/

/******************************************************************************
 Revision Notes:

For each change to this file, be sure to record:
1. Who made the change and when the change was made.
2. Why the change was made and the intended result.

  Date     By     Reason For Change
mm/dd/yy  XXX     -----------------

******************************************************************************/

